<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD><TITLE>Tcl_SubstObj manual page - Tcl Library Procedures</TITLE>
<link rel="stylesheet" href="../docs.css" type="text/css" media="all">
</HEAD>
<BODY><H2><a href="../contents.htm">Tcl8.6.11/Tk8.6.11 Documentation</a> <small>&gt;</small> <a href="contents.htm">Tcl C API</a> <small>&gt;</small> SubstObj</H2>
<H3><A HREF="../UserCmd/contents.htm">Tcl/Tk Applications</A> | <A HREF="../TclCmd/contents.htm">Tcl Commands</A> | <A HREF="../TkCmd/contents.htm">Tk Commands</A> | <A HREF="../ItclCmd/contents.htm">[incr Tcl] Package Commands</A> | <A HREF="../SqliteCmd/contents.htm">SQLite3 Package Commands</A> | <A HREF="../TdbcCmd/contents.htm">TDBC Package Commands</A> | <A HREF="../TdbcmysqlCmd/contents.htm">tdbc::mysql Package Commands</A> | <A HREF="../TdbcodbcCmd/contents.htm">tdbc::odbc Package Commands</A> | <A HREF="../TdbcpostgresCmd/contents.htm">tdbc::postgres Package Commands</A> | <A HREF="../TdbcsqliteCmd/contents.htm">tdbc::sqlite3 Package Commands</A> | <A HREF="../ThreadCmd/contents.htm">Thread Package Commands</A> | <A HREF="../TclLib/contents.htm">Tcl C API</A> | <A HREF="../TkLib/contents.htm">Tk C API</A> | <A HREF="../ItclLib/contents.htm">[incr Tcl] Package C API</A> | <A HREF="../TdbcLib/contents.htm">TDBC Package C API</A></H3>
<H3><A NAME="M2">NAME</A></H3>
Tcl_SubstObj &mdash; perform substitutions on Tcl values
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>#include &lt;tcl.h&gt;</B><BR>
<A HREF="../TclLib/Object.htm">Tcl_Obj</A> *<BR>
<B>Tcl_SubstObj</B>(<I>interp, objPtr, flags</I>)<BR>
<H3><A NAME="M4">ARGUMENTS</A></H3>
<DL class="arguments">
<DT><A HREF="../TclLib/Interp.htm">Tcl_Interp</A> <B>*interp</B> (in)<DD>
Interpreter in which to execute Tcl scripts and lookup variables.  If
an error occurs, the interpreter's result is modified to hold an error
message.
<P><DT><A HREF="../TclLib/Object.htm">Tcl_Obj</A> <B>*objPtr</B> (in)<DD>
A Tcl value containing the string to perform substitutions on.
<P><DT>int <B>flags</B> (in)<DD>
ORed combination of flag bits that specify which substitutions to
perform.  The flags <B>TCL_SUBST_COMMANDS</B>,
<B>TCL_SUBST_VARIABLES</B> and <B>TCL_SUBST_BACKSLASHES</B> are
currently supported, and <B>TCL_SUBST_ALL</B> is provided as a
convenience for the common case where all substitutions are desired.
<P></DL>
<H3><A NAME="M5">DESCRIPTION</A></H3>
The <B>Tcl_SubstObj</B> function is used to perform substitutions on
strings in the fashion of the <B><A HREF="../TclCmd/subst.htm">subst</A></B> command.  It gets the value
of the string contained in <I>objPtr</I> and scans it, copying
characters and performing the chosen substitutions as it goes to an
output value which is returned as the result of the function.  In the
event of an error occurring during the execution of a command or
variable substitution, the function returns NULL and an error message
is left in <I>interp</I>'s result.
<P>
Three kinds of substitutions are supported.  When the
<B>TCL_SUBST_BACKSLASHES</B> bit is set in <I>flags</I>, sequences that
look like backslash substitutions for Tcl commands are replaced by
their corresponding character.
<P>
When the <B>TCL_SUBST_VARIABLES</B> bit is set in <I>flags</I>,
sequences that look like variable substitutions for Tcl commands are
replaced by the contents of the named variable.
<P>
When the <B>TCL_SUBST_COMMANDS</B> bit is set in <I>flags</I>, sequences
that look like command substitutions for Tcl commands are replaced by
the result of evaluating that script.  Where an uncaught
&ldquo;continue exception&rdquo;
occurs during the evaluation of a command substitution, an
empty string is substituted for the command.  Where an uncaught
&ldquo;break exception&rdquo;
occurs during the evaluation of a command substitution, the
result of the whole substitution on <I>objPtr</I> will be truncated at
the point immediately before the start of the command substitution,
and no characters will be added to the result or substitutions
performed after that point.
<H3><A NAME="M6">SEE ALSO</A></H3>
<B><A HREF="../TclCmd/subst.htm">subst</A></B>
<H3><A NAME="M7">KEYWORDS</A></H3>
<A href="../Keywords/B.htm#backslash substitution">backslash substitution</A>, <A href="../Keywords/C.htm#command substitution">command substitution</A>, <A href="../Keywords/V.htm#variable substitution">variable substitution</A>
<div class="copy">Copyright &copy; 2001 Donal K. Fellows
</div>
</BODY></HTML>
